{template "header.html"}


<div class="row table-search-tool">
    <div class="col-md-12 col-sm-12">
        <label><button type="button" onclick="dr_beifen_cms('{dr_url('beifen/home/add')}')" class="btn blue btn-sm"> <i class="fa fa-copy"></i> {dr_lang('一键备份程序')}</button></label>
        <label><button type="button" onclick="dr_beifen_cms('{dr_url('beifen/home/db_add')}')" class="btn green btn-sm"> <i class="fa fa-database"></i> {dr_lang('一键备份数据库')}</button></label>
    </div>
</div>


<form class="form-horizontal" role="form" id="myform">
    {dr_form_hidden()}
<div class="row">

    <div class="col-md-6 col-sm-6">
        <div class="portlet light bordered myportlet">
            <div class="portlet-title tabbable-line">
                <div class="caption">
                    <i class="fa fa-copy font-blue"></i>
                    <span class="caption-subject font-blue"> {dr_lang('网站文件')} </span>
                </div>
            </div>
            <div class="portlet-body">

                <table class="table">
                    <thead>
                    <tr>
                        <th> {dr_lang('备份时间')} </th>
                        <th style="text-align: center"> {dr_lang('文件数')} </th>
                        <th> {dr_lang('操作')} </th>
                    </tr>
                    </thead>
                    <tbody>
                    {loop $file $t}
                    <tr>
                        <td> {$t.name} </td>
                        <td style="text-align: center">
                            <span class="badge badge-default"> {$t.files} </span>
                        </td>
                        <td>

                            <label><a href="javascript:dr_file_hf('{$t.id}')" class="btn blue btn-xs"> <i class="fa fa-exclamation-circle"></i> {dr_lang('恢复')} </a></label>
                            <label><a href="javascript:dr_ajax_option_url('{dr_url('beifen/home/del')}&id={$t.id}', '{dr_lang('你确定要这样操作吗？')}', '{FC_NOW_URL}');" class="btn red btn-xs"> <i class="fa fa-trash"></i> {dr_lang('删除')} </a></label>


                        </td>
                    </tr>
                    {/loop}
                    </tbody>
                </table>
            </div>
        </div>

    </div>
    <div class="col-md-6 col-sm-6">
        <div class="portlet light bordered myportlet">
            <div class="portlet-title tabbable-line">
                <div class="caption ">
                    <i class="fa fa-database font-green-sharp"></i>
                    <span class="caption-subject font-green-sharp"> {dr_lang('数据库')} </span>
                </div>
            </div>
            <div class="portlet-body">
                <table class="table">
                    <thead>
                    <tr>
                        <th> {dr_lang('备份时间')} </th>
                        <th style="text-align: center"> {dr_lang('数据量')} </th>
                        <th> {dr_lang('操作')} </th>
                    </tr>
                    </thead>
                    <tbody>
                    {loop $db $t}
                    <tr>
                        <td> {$t.name} </td>
                        <td style="text-align: center">
                            <span class="badge badge-default"> {$t.files} </span>
                        </td>
                        <td>
                            <label><a href="javascript:dr_db_hf('{$t.id}')" class="btn blue btn-xs"> <i class="fa fa-exclamation-circle"></i> {dr_lang('恢复')} </a></label>
                            <label><a href="javascript:dr_ajax_option_url('{dr_url('beifen/home/db_del')}&id={$t.id}', '{dr_lang('你确定要这样操作吗？')}', '{FC_NOW_URL}');" class="btn red btn-xs"> <i class="fa fa-trash"></i> {dr_lang('删除')} </a></label>
                        </td>
                    </tr>
                    {/loop}
                    </tbody>
                </table>

            </div>
        </div>

    </div>
</div></form>

<script type="text/javascript">
    function dr_file_hf(id) {
        layer.alert('{dr_lang('备份目录')}：{WRITEPATH}backups/file/'+id+'/<br>{dr_lang('安全起见，请手动恢复至网站')}', {
            title: '{dr_lang('文件恢复提示')}',
            shade: 0,
            closeBtn: 0
        });
    }
    function dr_beifen_cms(url) {
        layer.confirm(
            "{dr_lang('你确定要这样操作吗？')}",
            {
                icon: 3,
                shade: 0,
                title: lang['ts'],
                btn: [lang['ok'], lang['esc']]
            }, function(index){
                layer.close(index);
                layer.open({
                    type: 2,
                    title: '{dr_lang('备份')}',
                    scrollbar: false,
                    resize: true,
                    maxmin: true, //开启最大化最小化按钮
                    shade: 0,
                    area: ['80%', '80%'],
                    success: function(layero, index){
                        // 主要用于后台权限验证
                        var body = layer.getChildFrame('body', index);
                        var json = $(body).html();
                        if (json.indexOf('"code":0') > 0 && json.length < 150){
                            var obj = JSON.parse(json);
                            layer.closeAll(index);
                            dr_cmf_tips(0, obj.msg);
                        }
                    },
                    content: url
                });
            });
    }
    function dr_db_hf(name) {
        layer.confirm(
            "{dr_lang('你确定要这样操作吗？')}",
            {
                icon: 3,
                shade: 0,
                title: lang['ts'],
                btn: [lang['ok'], lang['esc']]
            }, function(index){
                layer.close(index);
                layer.open({
                    type: 2,
                    title: '{dr_lang('数据库恢复')}',
                    scrollbar: false,
                    resize: true,
                    maxmin: true, //开启最大化最小化按钮
                    shade: 0,
                    area: ['80%', '80%'],
                    success: function(layero, index){
                        // 主要用于后台权限验证
                        var body = layer.getChildFrame('body', index);
                        var json = $(body).html();
                        if (json.indexOf('"code":0') > 0 && json.length < 150){
                            var obj = JSON.parse(json);
                            layer.closeAll(index);
                            dr_cmf_tips(0, obj.msg);
                        }
                    },
                    content: '{dr_url('beifen/home/db_hf_add')}&id='+name
                });
            });
    }
</script>

{template "footer.html"}